<template>
    <LModalForm 
        :visible="visible"
        :confirmLoading="confirmLoading" 
        :title="title" 
        ref="contractTemplateAdd" 
        :formAttributes="formAttributes" 
        @handleOk="handleOk" 
        @handleCancel="handleCancel"
       ></LModalForm>

</template>

<script>
import LModalForm from "@/components/lt/form/LModalForm"
import request from '@/utils/request'
import md5 from 'md5'
import defaultSettings from '@/config/defaultSettings'

export default {
    name:'contractTemplateAdd',
    components:{
        LModalForm
    },
    data(){
        return{
            defaultSettings,
            title:'详情',
            visible:false,
            confirmLoading: false,
            model:{},
            formAttributes:{
              type:'',//collapse,tabs
              formItems:[
                {
                  title:'标签一',
                  columns:1,
                  fields:[
                    {field:'contractType',label:'合同类型',component:'select',dictCode:defaultSettings.数据字典.合同类型,rules: [{ required: true, message: '不能为空!' }]},
                    {field:'templateDesc',label:'备注',component:'input'},
                  ]
                },
              ]

            }


        }
    },
    methods:{
       
        edit (record) {
            this.visible = true;
            
        },
        handleOk(){
            const that = this;
            this.$refs.contractTemplateAdd.getForm().validateFields((err, values) => {
                if (!err) {
                   
                    let formData = Object.assign(this.model, values);
                   
                   
                    that.confirmLoading = true
                    request({url: '/WxContractTemplateController/save',method: 'post',data: formData}).then((res)=>{
                        if(res.success){
                            that.$message.success(res.message);
                            that.close()
                           
                        }else{
                            that.$message.warning(res.message);
                        }
                    }).finally(() => {
                        that.confirmLoading = false;
                        
                    })
                    
                }
            })
        },
        handleCancel(){
            this.visible=false
        },
        close () {
            this.$emit('close');
            this.visible = false;
        },
      
    },
    created(){
        
    },
}
</script>